package com.ruoyi.web.controller.object;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.object.domain.ObjectDemocraticParty;
import com.ruoyi.object.service.IObjectDemocraticPartyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 民主党派成员Controller
 * 
 * @author Lewis
 * @date 2022-05-11
 */
@RestController
@RequestMapping("/object/democratic")
public class ObjectDemocraticPartyController extends BaseController
{
    @Autowired
    private IObjectDemocraticPartyService objectDemocraticPartyService;

    /**
     * 查询民主党派成员列表
     */
    @PreAuthorize("@ss.hasPermi('object:democratic:list')")
    @GetMapping("/list")
    public TableDataInfo list(ObjectDemocraticParty objectDemocraticParty)
    {
        startPage();
        List<ObjectDemocraticParty> list = objectDemocraticPartyService.selectObjectDemocraticPartyList(objectDemocraticParty);
        return getDataTable(list);
    }

    /**
     * 导出民主党派成员列表
     */
    @PreAuthorize("@ss.hasPermi('object:democratic:export')")
    @Log(title = "民主党派成员", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ObjectDemocraticParty objectDemocraticParty)
    {
        List<ObjectDemocraticParty> list = objectDemocraticPartyService.selectObjectDemocraticPartyList(objectDemocraticParty);
        ExcelUtil<ObjectDemocraticParty> util = new ExcelUtil<ObjectDemocraticParty>(ObjectDemocraticParty.class);
        util.exportExcel(response, list, "民主党派成员数据");
    }

    /**
     * 获取民主党派成员详细信息
     */
    @PreAuthorize("@ss.hasPermi('object:democratic:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(objectDemocraticPartyService.selectObjectDemocraticPartyById(id));
    }

    /**
     * 新增民主党派成员
     */
    @PreAuthorize("@ss.hasPermi('object:democratic:add')")
    @Log(title = "民主党派成员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ObjectDemocraticParty objectDemocraticParty)
    {
        return toAjax(objectDemocraticPartyService.insertObjectDemocraticParty(objectDemocraticParty));
    }

    /**
     * 修改民主党派成员
     */
    @PreAuthorize("@ss.hasPermi('object:democratic:edit')")
    @Log(title = "民主党派成员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ObjectDemocraticParty objectDemocraticParty)
    {
        return toAjax(objectDemocraticPartyService.updateObjectDemocraticParty(objectDemocraticParty));
    }

    /**
     * 删除民主党派成员
     */
    @PreAuthorize("@ss.hasPermi('object:democratic:remove')")
    @Log(title = "民主党派成员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(objectDemocraticPartyService.deleteObjectDemocraticPartyByIds(ids));
    }
}
